package com.wangshouyu.mp.pay.unified;

import java.io.Serializable;
import java.util.Objects;

/**
 * @author 王守钰
 * @description 统一下单请求
 * @date 2020/8/13 13:38
 */
public class UnifiedRequest<Request extends BaseUnifiedRequest> implements Serializable {

    /**
     * 统一下单请求
     */
    private Request request;

    /**
     * 请求key
     */
    private String key;

    /**
     * 应用id
     */
    private String appId;

    public Request getRequest() {
        return request;
    }

    public void setRequest(Request request) {
        this.request = request;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        UnifiedRequest<?> that = (UnifiedRequest<?>) o;
        return Objects.equals(request, that.request) &&
                Objects.equals(key, that.key) &&
                Objects.equals(appId, that.appId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(request, key, appId);
    }

    @Override
    public String toString() {
        return "UnifiedRequest{" +
                "request=" + request +
                ", key='" + key + '\'' +
                ", appId='" + appId + '\'' +
                '}';
    }

    public UnifiedRequest(Request request, String key, String appId) {
        this.request = request;
        this.key = key;
        this.appId = appId;
    }

    public UnifiedRequest(Request request, String key) {
        this.request = request;
        this.key = key;
    }

    public UnifiedRequest() {
    }
}
